package cn.alm.ragdemo.controller;

import com.alibaba.cloud.ai.dashscope.chat.DashScopeChatModel;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

@RestController
@RequestMapping("client")
public class ClientController {

    @Autowired
    private ChatClient chatClient;

    @RequestMapping(value = "chat", produces = "text/html;charset=UTF-8")
    public Flux<String> chat(@RequestParam String message) {
        Flux<String> content = chatClient.prompt().user(message).stream().content();
        return content;
    }

}
